#include <stdio.h>
#define MAX 255

int length(char str[]) {
    int i = 0;
    while (str[i] != '\0') i++;
    return i;
}

void reverse(char str[]) {
    int i, len;
    char tmp;
    len = length(str);
    
    for (i = 0; i < len / 2; i++) {
        tmp = str[i];
        str[i] = str[len - 1 - i];
        str[len - i - 1] = tmp;
    }
}

void lower(char str[]) {
    int i;
    char tmp;
    for (i = 0; str[i] != '\0'; i++) {
        tmp = str[i];
        if (tmp >= 'A' && tmp <= 'Z') {
            str[i] = tmp + 32;
        }
    }
}

void upper(char str[]) {
    int i;
    char tmp;
    for (i = 0; str[i] != '\0'; i++) {
        tmp = str[i];
        if (tmp >= 'a' && tmp <= 'z') {
            str[i] = tmp - 32;
        }
    }

}

int is_cycle(char str[]) {
    int i, len, yes = 1;
    char tmp;
    len = length(str);
    
    for (i = 0; i < len / 2; i++) {
        if (str[i] != str[len - 1 - i]) {
            yes = 0;
            break;
        }
    }

    return yes;
}

int main() {
    char string[MAX] = {"heLlo,OlleH\0"};
    int len;

    printf("Raw: %s\n", string);

    len = length(string);
    printf("Length: %d\n", len);

    reverse(string);
    printf("Reversed: %s\n", string);

    lower(string);
    printf("Lower: %s\n", string);

    upper(string);
    printf("Upper: %s\n", string);
    
    printf("Cycle: ");
    if (is_cycle(string)) {
        printf("%s\n", "yes");
    } else {
        printf("%s\n", "no");
    }
        
    return 0;
}
